home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-07-05 | 44.5 KB | 1,924 lines |
- Article 43 of comp.sources.games:
- Path: ncrcce!rd1632!ncrlnk!ncrcae!hubcap!gatech!mcnc!seismo!rutgers!mit-eddie!uw-beaver!tektronix!tekgen!tekred!games-request
- From: games-request@tekred.TEK.COM
- Newsgroups: comp.sources.games
- Subject: v01i069: xmille - mille bournes game for X-windows, Part02/03
- Message-ID: <1359@tekred.TEK.COM>
- Date: 30 Jun 87 17:29:15 GMT
- Expires: 30 Jul 87 17:28:03 GMT
- Sender: billr@tekred.TEK.COM
- Lines: 1909
- Approved: billr@tekred.TEK.COM
-
- Submitted by: keithp@copper.TEK.COM (Keith Packard)
- Comp.sources.games: Volume 1, Issue 69
- Archive-name: xmille/Part02
-
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 2 (of 3)."
- # Contents: Makefile animate.c background.h card.h color.h extern.c
- # init.c mille.c mille.h misc.c move.c print.c roll.c save.c table.c
- # types.c ui.h varpush.c
- # Wrapped by billr@tekred on Mon Jun 29 17:24:36 1987
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f Makefile -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"Makefile\"
- else
- echo shar: Extracting \"Makefile\" \(1945 characters\)
- sed "s/^X//" >Makefile <<'END_OF_Makefile'
- X# @(#)Makefile 1.2 ULTRIX 6/29/84
- X#
- X# mille bourne game makefile
- X#
- X# @(#)Makefile 1.7 (Berkeley) 8/14/83
- X#
- XDESTROOT=
- XHEADERS=mille.h
- XCFILES= comp.c end.c extern.c init.c mille.c misc.c move.c print.c \
- X roll.c save.c types.c varpush.c ui.c drawcard.c animate.c
- XOBJS= comp.o end.o extern.o init.o mille.o misc.o move.o print.o \
- X roll.o save.o types.o varpush.o ui.o drawcard.o animate.o
- XPOBJS= comp.po end.po extern.po init.po mille.po misc.po move.po \
- X roll.po print.po save.po types.po varpush.po ui.po drawcard.po animate.po
- XCRL=
- XL= control/control.a cards/cardlib.a -lX -lm
- XLIBS= ${CRL} ${L}
- XDEFS=
- XCFLAGS= -O ${DEFS}
- XBINDIR= ${DESTROOT}/usr/games
- X.SUFFIXES: .po .i
- X
- X.c.po:
- X rm -f x.c ; ln $*.c x.c
- X ${CC} ${CFLAGS} -p -c x.c
- X mv x.o $*.po
- X
- X.c.i:
- X ${CC} ${CFLAGS} -P $*.c
- X
- Xa.out: ${OBJS} ${CRL} control/control.a cards/cardlib.a
- X ${CC} ${CFLAGS} ${OBJS} ${LIBS}
- X
- Xmille: ${OBJS} ${CRL}
- X ${CC} ${CFLAGS} -o mille ${OBJS} ${LIBS}
- X
- Xcontrol/control.a: always
- X cd control; make control.a
- X
- Xcards/cardlib.a: always
- X cd cards; make cardlib.a
- X
- Xalways:
- X
- Xinstall: mille
- X install -c -s mille ${BINDIR}
- X
- Xpmb: ${POBJS} ../pcrlib
- X ${CC} ${CFLAGS} -p -o pmb ${POBJS} ../pcrlib -ltermlib
- X
- Xmille.po: mille.c
- X rm -f x.c ; ln mille.c x.c
- X ${CC} ${CFLAGS} -DPROF -p -c x.c
- X mv x.o mille.po
- X
- Xtable: table.o extern.o
- X ${CC} ${CFLAGS} -i -o table table.o extern.o
- X
- Xanimate.o ui.o: ui.h
- X
- Xreaddump: readdump.o extern.o varpush.o
- X ${CC} ${CFLAGS} -i -o readdump readdump.o extern.o varpush.o
- X
- Xctags:
- X ctags ${HEADERS} ${CFILES}
- X ed - tags < :ctfix
- X sort tags -o tags
- X
- Xlint:
- X lint -hxb ${DEFS} ${CFILES} ${L} > lint.out
- X
- Xmille.ar:
- X ar ruv mille.ar Makefile tags ${HEADERS} ${CFILES}
- X
- Xtar:
- X tar rvf /dev/rmt0 Makefile tags :ctfix ${HEADERS} ${CFILES}
- X
- Xlpr:
- X pr Makefile ${HEADERS} ${CFILES} tags | lpr ; lpq
- X
- Xclean:
- X rm -f ${OBJS} ${POBJS} core ? a.out mille
- X
- Xclobber: clean
- X rm -f *.[ch] Makefile
- X
- Xsccsinfo:
- X sccs info
- X
- Xsccsget:
- X sccs get SCCS
- X
- X.DEFAULT:
- X sccs get $<
- END_OF_Makefile
- if test 1945 -ne `wc -c <Makefile`; then
- echo shar: \"Makefile\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f animate.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"animate.c\"
- else
- echo shar: Extracting \"animate.c\" \(4533 characters\)
- sed "s/^X//" >animate.c <<'END_OF_animate.c'
- X/*
- X * animation
- X */
- X
- X# include "mille.h"
- X# include "ui.h"
- X# include "card.h"
- X# include <math.h>
- X
- Xanimate_move (player, orig_type, orig_arg, dest_type, dest_arg)
- X{
- X int ox, oy, dx, dy;
- X
- X compute_position (player, orig_type, orig_arg, &ox, &oy);
- X compute_position (player, dest_type, dest_arg, &dx, &dy);
- X do_animate (ox, oy, dx, dy);
- X}
- X
- X# define abs(x) ((x) < 0 ? -(x) : (x))
- X
- X# define SPEED_FACTOR (2.5)
- X# define accerate(v,r) ((v) + (0.1 * (r)))
- X
- Xstatic
- Xdo_animate (ox, oy, dx, dy)
- X{
- X double x, y;
- X double xc, yc;
- X int xd, yd;
- X int xp, yp;
- X int x1, y1, x2, y2, x3, y3, x4, y4;
- X int ix, iy;
- X double dist;
- X double rx, ry;
- X
- X x = ox;
- X y = oy;
- X xd = dx - ox;
- X yd = dy - oy;
- X dist = sqrt ((double) xd * xd + yd * yd);
- X rx = (double) xd / dist;
- X ry = (double) yd / dist;
- X xc = SPEED_FACTOR * rx;
- X yc = SPEED_FACTOR * ry;
- X xp = yp = -32767;
- X XFlush ();
- X while (abs(dx - x) > abs (xc) || abs(dy - y) > abs (yc)) {
- X ix = x;
- X iy = y;
- X if (xp == -32767)
- X draw_square (ix, iy, ix + WIDTH, iy + HEIGHT);
- X else {
- X if (xp < ix) {
- X x1 = xp + WIDTH;
- X x2 = ix + WIDTH;
- X x3 = ix;
- X x4 = ix + WIDTH;
- X } else if (xp > ix) {
- X x1 = ix;
- X x2 = xp;
- X x3 = ix;
- X x4 = ix + WIDTH;
- X } else {
- X x1 = -32767;
- X x2 = -32767;
- X x3 = ix;
- X x4 = ix + WIDTH;
- X }
- X if (yp < iy) {
- X y1 = iy;
- X y2 = yp + HEIGHT;
- X y3 = yp + HEIGHT;
- X y4 = iy + HEIGHT;
- X } else if (yp > iy) {
- X y1 = yp;
- X y2 = iy + HEIGHT;
- X y3 = iy;
- X y4 = yp;
- X } else {
- X y1 = iy;
- X y2 = iy + HEIGHT;
- X y3 = -32767;
- X y4 = -32767;
- X }
- X if (x1 != -32767 && y1 != -32767)
- X draw_square (x1, y1, x2, y2);
- X if (x3 != -32767 && y3 != -32767)
- X draw_square (x3, y3, x4, y4);
- X if (ix < xp) {
- X x1 = ix + WIDTH;
- X x2 = xp + WIDTH;
- X x3 = xp;
- X x4 = xp + WIDTH;
- X } else if (ix > xp) {
- X x1 = xp;
- X x2 = ix;
- X x3 = xp;
- X x4 = xp + WIDTH;
- X } else {
- X x1 = -32767;
- X x2 = -32767;
- X x3 = xp;
- X x4 = xp + WIDTH;
- X }
- X if (iy < yp) {
- X y1 = yp;
- X y2 = iy + HEIGHT;
- X y3 = iy + HEIGHT;
- X y4 = yp + HEIGHT;
- X } else if (iy > yp) {
- X y1 = iy;
- X y2 = yp + HEIGHT;
- X y3 = yp;
- X y4 = iy;
- X } else {
- X y1 = yp;
- X y2 = yp + HEIGHT;
- X y3 = -32767;
- X y4 = -32767;
- X }
- X if (x1 != -32767 && y1 != -32767)
- X draw_square (x1, y1, x2, y2);
- X if (x3 != -32767 && y3 != -32767)
- X draw_square (x3, y3, x4, y4);
- X }
- X xp = ix;
- X yp = iy;
- X if (abs (dx - x) > xc)
- X x += xc;
- X if (abs (dy - y) > yc)
- X y += yc;
- X xc = accerate(xc, rx);
- X yc = accerate(yc, ry);
- X }
- X draw_square (xp, yp, xp+WIDTH, yp+HEIGHT);
- X XFlush ();
- X}
- X
- Xstatic
- Xdraw_square (x1, y1, x2, y2)
- X{
- X XPixFill (xwindow, x1, y1, x2-x1, y2-y1, colorMap[BLACK_COLOR].pixel, 0,
- X GXxor, AllPlanes);
- X}
- X
- Xstatic
- Xcompute_position (player, type, arg, xp, yp)
- Xint *xp, *yp;
- X{
- X switch (type) {
- X case ANIMATE_HAND:
- X switch (player) {
- X case 0:
- X *xp = HUM_HAND_X + (WIDTH + PAD_CARD) * arg;
- X *yp = HUM_HAND_Y;
- X break;
- X case 1:
- X *xp = COMP_HAND_X + (WIDTH + PAD_CARD) * arg;
- X *yp = COMP_HAND_Y;
- X break;
- X }
- X break;
- X case ANIMATE_DECK:
- X *xp = DECK_X;
- X *yp = DECK_Y;
- X break;
- X case ANIMATE_DISC:
- X *xp = DISCARD_X;
- X *yp = DISCARD_Y;
- X break;
- X case ANIMATE_MILES:
- X switch (player) {
- X case 0:
- X *xp = HUM_PLAY_X + (WIDTH + PAD_CARD) * (2 + C_200 - arg);
- X *yp = HUM_PLAY_Y;
- X break;
- X case 1:
- X *xp = COMP_PLAY_X + (WIDTH + PAD_CARD) * (2 + C_200 - arg);
- X *yp = COMP_PLAY_Y;
- X break;
- X }
- X break;
- X case ANIMATE_BATTLE:
- X switch (player) {
- X case 0:
- X *xp = HUM_PLAY_X + WIDTH + PAD_CARD;
- X *yp = HUM_PLAY_Y;
- X break;
- X case 1:
- X *xp = COMP_PLAY_X + WIDTH + PAD_CARD;
- X *yp = COMP_PLAY_Y;
- X break;
- X }
- X break;
- X case ANIMATE_SPEED:
- X switch (player) {
- X case 0:
- X *xp = HUM_PLAY_X;
- X *yp = HUM_PLAY_Y;
- X break;
- X case 1:
- X *xp = COMP_PLAY_X;
- X *yp = COMP_PLAY_Y;
- X break;
- X }
- X break;
- X case ANIMATE_OBATTLE:
- X switch (1-player) {
- X case 0:
- X *xp = HUM_PLAY_X + WIDTH + PAD_CARD;
- X *yp = HUM_PLAY_Y;
- X break;
- X case 1:
- X *xp = COMP_PLAY_X + WIDTH + PAD_CARD;
- X *yp = COMP_PLAY_Y;
- X break;
- X }
- X break;
- X case ANIMATE_OSPEED:
- X switch (1-player) {
- X case 0:
- X *xp = HUM_PLAY_X;
- X *yp = HUM_PLAY_Y;
- X break;
- X case 1:
- X *xp = COMP_PLAY_X;
- X *yp = COMP_PLAY_Y;
- X break;
- X }
- X break;
- X case ANIMATE_SAFETY:
- X switch (player) {
- X case 0:
- X *xp = HUM_SAFE_X + safety_offsets[arg - S_CONV].x;
- X *yp = HUM_SAFE_Y + safety_offsets[arg - S_CONV].y;
- X break;
- X case 1:
- X *xp = COMP_SAFE_X + safety_offsets[arg - S_CONV].x;
- X *yp = COMP_SAFE_Y + safety_offsets[arg - S_CONV].y;
- X break;
- X }
- X break;
- X }
- X}
- END_OF_animate.c
- if test 4533 -ne `wc -c <animate.c`; then
- echo shar: \"animate.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f background.h -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"background.h\"
- else
- echo shar: Extracting \"background.h\" \(17 characters\)
- sed "s/^X//" >background.h <<'END_OF_background.h'
- X# include "fill"
- END_OF_background.h
- if test 17 -ne `wc -c <background.h`; then
- echo shar: \"background.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f card.h -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"card.h\"
- else
- echo shar: Extracting \"card.h\" \(39 characters\)
- sed "s/^X//" >card.h <<'END_OF_card.h'
- X# define HEIGHT 150
- X# define WIDTH 100
- END_OF_card.h
- if test 39 -ne `wc -c <card.h`; then
- echo shar: \"card.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f color.h -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"color.h\"
- else
- echo shar: Extracting \"color.h\" \(299 characters\)
- sed "s/^X//" >color.h <<'END_OF_color.h'
- X/*
- X * color.h
- X *
- X * definitions for standard colors
- X */
- X
- X# define BLACK_COLOR 0
- X# define WHITE_COLOR 1
- X# define RED_COLOR 2
- X# define GREEN_COLOR 3
- X# define GREY_COLOR 4
- X# define BLUE_COLOR 5
- X# define NUM_COLOR 6
- X
- X
- Xstruct color {
- X char *name;
- X int pixel;
- X};
- X
- Xextern struct color colorMap[NUM_COLOR];
- END_OF_color.h
- if test 299 -ne `wc -c <color.h`; then
- echo shar: \"color.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f extern.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"extern.c\"
- else
- echo shar: Extracting \"extern.c\" \(2988 characters\)
- sed "s/^X//" >extern.c <<'END_OF_extern.c'
- X# include "mille.h"
- X
- X/*
- X * @(#)extern.c 1.1 (Berkeley) 4/1/82
- X */
- X
- Xbool Debug, /* set if debugging code on */
- X Finished, /* set if current hand is finished */
- X Next, /* set if changing players */
- X On_exit, /* set if game saved on exiting */
- X Order, /* set if hand should be sorted */
- X Saved; /* set if game just saved */
- X
- Xchar *Fromfile = NULL; /* startup file for game */
- X
- Xint Card_no, /* Card number for current move */
- X End, /* End value for current hand */
- X Handstart = COMP, /* Player who starts hand */
- X Movetype, /* Current move type */
- X Play, /* Current player */
- X Numgos, /* Number of Go cards used by computer */
- X WIndow = W_SMALL, /* Current window wanted */
- X Numseen[NUM_CARDS], /* Number of cards seen in current hand */
- X Value[NUM_MILES] = { /* Value of mileage cards */
- X 25, 50, 75, 100, 200
- X },
- X Numcards[NUM_CARDS] = { /* Number of cards in deck */
- X 10, /* C_25 */
- X 10, /* C_50 */
- X 10, /* C_75 */
- X 12, /* C_100 */
- X 4, /* C_200 */
- X 2, /* C_EMPTY */
- X 2, /* C_FLAT */
- X 2, /* C_CRASH */
- X 4, /* C_STOP */
- X 3, /* C_LIMIT */
- X 6, /* C_GAS */
- X 6, /* C_SPARE */
- X 6, /* C_REPAIRS */
- X 14, /* C_GO */
- X 6, /* C_END_LIMIT */
- X 1, /* C_GAS_SAFE */
- X 1, /* C_SPARE_SAFE */
- X 1, /* C_DRIVE_SAFE */
- X 1, /* C_RIGHT_WAY */
- X 0 /* C_INIT */
- X };
- X Numneed[NUM_CARDS] = { /* number of cards needed per hand */
- X 0, /* C_25 */
- X 0, /* C_50 */
- X 0, /* C_75 */
- X 0, /* C_100 */
- X 0, /* C_200 */
- X 2, /* C_EMPTY */
- X 2, /* C_FLAT */
- X 2, /* C_CRASH */
- X 4, /* C_STOP */
- X 3, /* C_LIMIT */
- X 2, /* C_GAS */
- X 2, /* C_SPARE */
- X 2, /* C_REPAIRS */
- X 10, /* C_GO */
- X 3, /* C_END_LIMIT */
- X 1, /* C_GAS_SAFE */
- X 1, /* C_SPARE_SAFE */
- X 1, /* C_DRIVE_SAFE */
- X 1, /* C_RIGHT_WAY */
- X 0 /* C_INIT */
- X };
- X
- XCARD Discard, /* Top of discard pile */
- X *Topcard, /* Pointer to next card to be picked */
- X Opposite[NUM_CARDS] = { /* Opposites of each card */
- X C_25, C_50, C_75, C_100, C_200, C_GAS, C_SPARE,
- X C_REPAIRS, C_GO, C_END_LIMIT, C_EMPTY, C_FLAT, C_CRASH,
- X C_STOP, C_LIMIT, C_EMPTY, C_FLAT, C_CRASH, C_STOP, C_INIT
- X },
- X Deck[DECK_SZ] = { /* Current deck */
- X C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_25,
- X C_50, C_50, C_50, C_50, C_50, C_50, C_50, C_50, C_50, C_50,
- X C_75, C_75, C_75, C_75, C_75, C_75, C_75, C_75, C_75, C_75,
- X C_100, C_100, C_100, C_100, C_100, C_100, C_100, C_100, C_100,
- X C_100, C_100, C_100,
- X C_200, C_200, C_200, C_200,
- X C_EMPTY, C_EMPTY,
- X C_FLAT, C_FLAT,
- X C_CRASH, C_CRASH,
- X C_STOP, C_STOP, C_STOP, C_STOP,
- X C_LIMIT, C_LIMIT, C_LIMIT,
- X C_GAS, C_GAS, C_GAS, C_GAS, C_GAS, C_GAS,
- X C_SPARE, C_SPARE, C_SPARE, C_SPARE, C_SPARE, C_SPARE,
- X C_REPAIRS, C_REPAIRS, C_REPAIRS, C_REPAIRS, C_REPAIRS,
- X C_REPAIRS,
- X C_END_LIMIT, C_END_LIMIT, C_END_LIMIT, C_END_LIMIT, C_END_LIMIT,
- X C_END_LIMIT,
- X C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, C_GO, C_GO,
- X C_GO, C_GO, C_GO, C_GO,
- X C_GAS_SAFE, C_SPARE_SAFE, C_DRIVE_SAFE, C_RIGHT_WAY
- X };
- X
- XFILE *outf;
- X
- XPLAY Player[2]; /* Player descriptions */
- END_OF_extern.c
- if test 2988 -ne `wc -c <extern.c`; then
- echo shar: \"extern.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f init.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"init.c\"
- else
- echo shar: Extracting \"init.c\" \(1198 characters\)
- sed "s/^X//" >init.c <<'END_OF_init.c'
- X# include "mille.h"
- X
- X/*
- X * @(#)init.c 1.1 (Berkeley) 4/1/82
- X */
- X
- Xinit() {
- X
- X reg PLAY *pp;
- X reg int i, j;
- X reg CARD card;
- X
- X for (j = 0; j < C_RIGHT_WAY; j++)
- X Numseen[j] = 0;
- X Numgos = 0;
- X
- X for (i = 0; i < 2; i++) {
- X pp = &Player[i];
- X pp->hand[0] = C_INIT;
- X for (j = 0; j < NUM_SAFE; j++) {
- X pp->safety[j] = S_UNKNOWN;
- X pp->coups[j] = FALSE;
- X }
- X for (j = 1; j < HAND_SZ; j++) {
- X pp->hand[j] = *--Topcard;
- X if (i == COMP) {
- X account(card = *Topcard);
- X if (issafety(card))
- X pp->safety[card - S_CONV] = S_IN_HAND;
- X }
- X }
- X pp->mileage = 0;
- X pp->hand_tot = 0;
- X pp->safescore = 0;
- X pp->coupscore = 0;
- X pp->can_go = FALSE;
- X pp->speed = C_INIT;
- X pp->battle = C_INIT;
- X pp->new_speed = FALSE;
- X pp->new_battle = FALSE;
- X for (j = 0; j < NUM_MILES; j++)
- X pp->nummiles[j] = 0;
- X }
- X if (Order)
- X sort(Player[PLAYER].hand);
- X Discard = C_INIT;
- X Finished = FALSE;
- X End = 700;
- X}
- X
- Xshuffle() {
- X
- X reg int i, r;
- X reg CARD temp;
- X
- X for (i = 0; i < DECK_SZ; i++) {
- X r = roll(1, DECK_SZ) - 1;
- X if (r < 0 || r > DECK_SZ - 1) {
- X fprintf(stderr, "shuffle: card no. error: %d\n", r);
- X die();
- X }
- X temp = Deck[r];
- X Deck[r] = Deck[i];
- X Deck[i] = temp;
- X }
- X Topcard = &Deck[DECK_SZ];
- X}
- END_OF_init.c
- if test 1198 -ne `wc -c <init.c`; then
- echo shar: \"init.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f mille.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"mille.c\"
- else
- echo shar: Extracting \"mille.c\" \(1892 characters\)
- sed "s/^X//" >mille.c <<'END_OF_mille.c'
- X# include "mille.h"
- X# include <signal.h>
- X# ifdef attron
- X# include <term.h>
- X# endif attron
- X
- X/*
- X * @(#)mille.c 1.3 (Berkeley) 5/10/83
- X */
- X
- Xint rub();
- X
- Xchar _sobuf[BUFSIZ];
- X
- Xmain(ac, av)
- Xreg int ac;
- Xreg char *av[]; {
- X
- X reg bool restore;
- X double avs[3];
- X
- X if (strcmp(av[0], "a.out") == 0) {
- X outf = fopen("q", "w");
- X setbuf(outf, 0);
- X Debug = TRUE;
- X }
- X restore = FALSE;
- X# ifdef pdp11
- X if (geteuid() != ARNOLD) {
- X loadav(avs);
- X if (avs[2] > 9.0) {
- X printf("Sorry. The load average is too high.\n");
- X printf("Please try again later\n");
- X exit(1);
- X }
- X }
- X# endif
- X switch (ac) {
- X case 2:
- X rest_f(av[1]);
- X restore = TRUE;
- X case 1:
- X break;
- X default:
- X printf("usage: milles [ restore_file ]\n");
- X exit(-1);
- X /* NOTREACHED */
- X }
- X setbuf(stdout, _sobuf);
- X Play = PLAYER;
- X init_ui ();
- X# ifndef PROF
- X srand(getpid());
- X# else
- X srand(0);
- X# endif
- X signal(SIGINT, rub);
- X for (;;) {
- X if (!restore || (Player[PLAYER].total >= 5000
- X || Player[COMP].total >= 5000)) {
- X if (Player[COMP].total < Player[PLAYER].total)
- X Player[PLAYER].games++;
- X else if (Player[COMP].total > Player[PLAYER].total)
- X Player[COMP].games++;
- X Player[COMP].total = 0;
- X Player[PLAYER].total = 0;
- X }
- X do {
- X if (!restore)
- X Handstart = Play = other(Handstart);
- X if (!restore || On_exit) {
- X shuffle();
- X init();
- X }
- X newboard();
- X if (restore)
- X Error (Initstr);
- X prboard();
- X do {
- X domove();
- X if (Finished)
- X newscore();
- X prboard();
- X } while (!Finished);
- X check_more();
- X restore = On_exit = FALSE;
- X } while (Player[COMP].total < 5000
- X && Player[PLAYER].total < 5000);
- X }
- X}
- X
- X/*
- X * Routine to trap rubouts, and make sure they really want to
- X * quit.
- X */
- Xrub() {
- X
- X signal(SIGINT, 1);
- X if (getyn("Really? "))
- X die();
- X signal(SIGINT, rub);
- X}
- X
- X/*
- X * Time to go beddy-by
- X */
- Xdie() {
- X
- X signal(SIGINT, 1);
- X if (outf)
- X fflush(outf);
- X finish_ui ();
- X exit(1);
- X}
- END_OF_mille.c
- if test 1892 -ne `wc -c <mille.c`; then
- echo shar: \"mille.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f mille.h -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"mille.h\"
- else
- echo shar: Extracting \"mille.h\" \(3206 characters\)
- sed "s/^X//" >mille.h <<'END_OF_mille.h'
- X# include <ctype.h>
- X# include <stdio.h>
- X
- Xtypedef char bool;
- X# define reg register
- X# define TRUE 1
- X# define FALSE 0
- X
- X/*
- X * @(#)mille.h 1.1 (Berkeley) 4/1/82
- X */
- X
- X/*
- X * Miscellaneous constants
- X */
- X
- X# define unsgn unsigned
- X# define CARD short
- X
- X# ifdef vax
- X# define ARNOLD 78 /* my uid */
- X# else
- X# define ARNOLD 24601 /* my uid */
- X# endif
- X
- X# define GURP 28672 /* bad uid */
- X# define MAXUSERS 35 /* max # of users for startup */
- X# define HAND_SZ 7 /* number of cards in a hand */
- X# define DECK_SZ 101 /* number of cards in decks */
- X# define NUM_SAFE 4 /* number of saftey cards */
- X# define NUM_MILES 5 /* number of milestones types */
- X# define NUM_CARDS 20 /* number of types of cards */
- X
- X# define PLAYER 0
- X# define COMP 1
- X
- X# define W_SMALL 0 /* Small (initial) window */
- X# define W_FULL 1 /* Full (final) window */
- X
- X/*
- X * Move types
- X */
- X
- X# define M_DISCARD 0
- X# define M_DRAW 1
- X# define M_PLAY 2
- X# define M_ORDER 3
- X# define M_REASONABLE 4
- X
- X/*
- X * Scores
- X */
- X
- X# define SC_SAFETY 100
- X# define SC_ALL_SAFE 300
- X# define SC_COUP 300
- X# define SC_TRIP 400
- X# define SC_SAFE 300
- X# define SC_DELAY 300
- X# define SC_EXTENSION 200
- X# define SC_SHUT_OUT 500
- X
- X/*
- X * safety descriptions
- X */
- X
- X# define S_UNKNOWN 0 /* location of safety unknown */
- X# define S_IN_HAND 1 /* safety in player's hand */
- X# define S_PLAYED 2 /* safety has been played */
- X# define S_GAS_SAFE 0 /* Gas safety card index */
- X# define S_SPARE_SAFE 1 /* Tire safety card index */
- X# define S_DRIVE_SAFE 2 /* Driveing safety card index */
- X# define S_RIGHT_WAY 3 /* Right-of-Way card index */
- X# define S_CONV 15 /* conversion from C_ to S_ */
- X
- X/*
- X * card numbers
- X */
- X
- X# define C_INIT -1
- X# define C_25 0
- X# define C_50 1
- X# define C_75 2
- X# define C_100 3
- X# define C_200 4
- X# define C_EMPTY 5
- X# define C_FLAT 6
- X# define C_CRASH 7
- X# define C_STOP 8
- X# define C_LIMIT 9
- X# define C_GAS 10
- X# define C_SPARE 11
- X# define C_REPAIRS 12
- X# define C_GO 13
- X# define C_END_LIMIT 14
- X# define C_GAS_SAFE 15
- X# define C_SPARE_SAFE 16
- X# define C_DRIVE_SAFE 17
- X# define C_RIGHT_WAY 18
- X
- Xtypedef struct {
- X bool coups[NUM_SAFE];
- X bool can_go;
- X bool new_battle;
- X bool new_speed;
- X short safety[NUM_SAFE];
- X short nummiles[NUM_MILES];
- X CARD hand[HAND_SZ];
- X CARD battle;
- X CARD speed;
- X int mileage;
- X int hand_tot;
- X int safescore;
- X int coupscore;
- X int total;
- X int games;
- X} PLAY;
- X
- X/*
- X * animation constants
- X */
- X
- X# define ANIMATE
- X# define ANIMATE_HAND 0
- X# define ANIMATE_DECK 1
- X# define ANIMATE_DISC 2
- X# define ANIMATE_MILES 3
- X# define ANIMATE_BATTLE 4
- X# define ANIMATE_SPEED 5
- X# define ANIMATE_OBATTLE 6
- X# define ANIMATE_OSPEED 7
- X# define ANIMATE_SAFETY 8
- X
- X/*
- X * macros
- X */
- X
- X# define other(x) (1 - x)
- X# define nextplay() (Play = other(Play))
- X# define nextwin(x) (1 - x)
- X# define opposite(x) (Opposite[x])
- X# define issafety(x) (x >= C_GAS_SAFE)
- X
- X/*
- X * externals
- X */
- X
- Xextern bool Debug, Finished, Next, On_exit, Order, Saved;
- X
- Xextern char *C_fmt, **C_name, *Fromfile, Initstr[];
- X
- Xextern int Card_no, End, Handstart, Movetype, Numcards[], Numgos,
- X Numneed[], Numseen[NUM_CARDS], Play, Value[], WIndow;
- X
- Xextern CARD Deck[DECK_SZ], Discard, Opposite[NUM_CARDS], *Topcard;
- X
- Xextern FILE *outf;
- X
- Xextern PLAY Player[2];
- X
- X/*
- X * functions
- X */
- X
- XCARD getcard();
- END_OF_mille.h
- if test 3206 -ne `wc -c <mille.h`; then
- echo shar: \"mille.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f misc.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"misc.c\"
- else
- echo shar: Extracting \"misc.c\" \(1986 characters\)
- sed "s/^X//" >misc.c <<'END_OF_misc.c'
- X#include "mille.h"
- X# ifdef attron
- X# include <term.h>
- X# define _tty cur_term->Nttyb
- X# endif attron
- X
- X/*
- X * @(#)misc.c 1.3 (Berkeley) 7/2/83
- X */
- X
- X#define NUMSAFE 4
- X
- X/* VARARGS1 */
- Xerror(str, arg)
- Xchar *str;
- X{
- X Error (str, arg);
- X Beep ();
- X update_ui ();
- X return FALSE;
- X}
- X
- Xcheck_ext(forcomp)
- Xreg bool forcomp; {
- X
- X
- X if (End == 700)
- X if (Play == PLAYER) {
- X if (getyn("Extension? ")) {
- Xextend:
- X if (!forcomp)
- X End = 1000;
- X return TRUE;
- X }
- X else {
- Xdone:
- X if (!forcomp)
- X Finished = TRUE;
- X return FALSE;
- X }
- X }
- X else {
- X reg PLAY *pp, *op;
- X reg int i, safe, miles;
- X
- X pp = &Player[COMP];
- X op = &Player[PLAYER];
- X for (safe = 0, i = 0; i < NUMSAFE; i++)
- X if (pp->safety[i] != S_UNKNOWN)
- X safe++;
- X if (safe < 2)
- X goto done;
- X if (op->mileage == 0 || onecard(op)
- X || (op->can_go && op->mileage >= 500))
- X goto done;
- X for (miles = 0, i = 0; i < NUMSAFE; i++)
- X if (op->safety[i] != S_PLAYED
- X && pp->safety[i] == S_UNKNOWN)
- X miles++;
- X if (miles + safe == NUMSAFE)
- X goto extend;
- X for (miles = 0, i = 0; i < HAND_SZ; i++)
- X if ((safe = pp->hand[i]) <= C_200)
- X miles += Value[safe];
- X if (miles + (Topcard - Deck) * 3 > 1000)
- X goto extend;
- X goto done;
- X }
- X else
- X goto done;
- X}
- X
- X/*
- X * Check to see if more games are desired. If not, and game
- X * came from a saved file, make sure that they don't want to restore
- X * it. Exit appropriately.
- X */
- Xcheck_more() {
- X
- X FlushInput ();
- X
- X On_exit = TRUE;
- X if (Player[PLAYER].total >= 5000 || Player[COMP].total >= 5000)
- X if (getyn("Another game? "))
- X return;
- X else {
- X /*
- X * must do accounting normally done in main()
- X */
- X if (Player[PLAYER].total > Player[COMP].total)
- X Player[PLAYER].games++;
- X else if (Player[PLAYER].total < Player[COMP].total)
- X Player[COMP].games++;
- X Player[COMP].total = 0;
- X Player[PLAYER].total = 0;
- X }
- X else
- X if (getyn("Another hand? "))
- X return;
- X if (!Saved && getyn("Save game? "))
- X if (!save())
- X return;
- X die();
- X}
- END_OF_misc.c
- if test 1986 -ne `wc -c <misc.c`; then
- echo shar: \"misc.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f move.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"move.c\"
- else
- echo shar: Extracting \"move.c\" \(8310 characters\)
- sed "s/^X//" >move.c <<'END_OF_move.c'
- X#include "mille.h"
- X
- X/*
- X * @(#)move.c 1.3 (Berkeley) 7/2/83
- X */
- X
- X#ifdef CTRL
- X#undef CTRL
- X#endif
- X#define CTRL(c) (c - 'A' + 1)
- X
- Xchar *Movenames[] = {
- X "M_DISCARD", "M_DRAW", "M_PLAY", "M_ORDER"
- X };
- X
- Xchar *playcard (), *sprint ();
- X
- Xdomove()
- X{
- X reg PLAY *pp;
- X reg int i, j;
- X reg bool goodplay;
- X char *foo;
- X
- X pp = &Player[Play];
- X if (Play == PLAYER)
- X getmove();
- X else
- X calcmove();
- X Next = FALSE;
- X goodplay = TRUE;
- X switch (Movetype) {
- X case M_DISCARD:
- Xtrydiscard: ;
- X if (haspicked(pp)) {
- X if (pp->hand[Card_no] == C_INIT)
- X if (Card_no == 6)
- X Finished = TRUE;
- X else
- X error("no card there");
- X else {
- X Discard = pp->hand[Card_no];
- X pp->hand[Card_no] = C_INIT;
- X#ifdef ANIMATE
- X animate_move (Play, ANIMATE_HAND, Card_no,
- X ANIMATE_DISC, Discard);
- X#endif
- X Next = TRUE;
- X if (Play == PLAYER)
- X account(Discard);
- X }
- X }
- X else
- X error("must pick first");
- X break;
- X case M_REASONABLE:
- X case M_PLAY:
- X foo = playcard(pp);
- X if (foo) {
- X if (Movetype == M_REASONABLE)
- X goto trydiscard;
- X error (foo);
- X goodplay = 0;
- X } else
- X goodplay = 1;
- X break;
- X case M_DRAW:
- X Card_no = 0;
- X if (Topcard <= Deck)
- X error("no more cards");
- X else if (haspicked(pp))
- X error("already picked");
- X else {
- X pp->hand[0] = *--Topcard;
- X#ifdef ANIMATE
- X animate_move (Play, ANIMATE_DECK, pp->hand[0], ANIMATE_HAND, 0);
- X#endif
- X if (Debug)
- X fprintf(outf, "DOMOVE: Draw %s\n", C_name[*Topcard]);
- Xacc:
- X if (Play == COMP) {
- X account(*Topcard);
- X if (issafety(*Topcard))
- X pp->safety[*Topcard-S_CONV] = S_IN_HAND;
- X }
- X if (pp->hand[1] == C_INIT && Topcard > Deck) {
- X Card_no = 1;
- X pp->hand[1] = *--Topcard;
- X if (Debug)
- X fprintf(outf, "DOMOVE: Draw %s\n", C_name[*Topcard]);
- X goto acc;
- X }
- X pp->new_battle = FALSE;
- X pp->new_speed = FALSE;
- X }
- X break;
- X
- X case M_ORDER:
- X break;
- X }
- X /*
- X * move blank card to top by one of two methods. If the
- X * computer's hand was sorted, the randomness for picking
- X * between equally valued cards would be lost
- X */
- X if (Order && Movetype != M_DRAW && goodplay && pp == &Player[PLAYER])
- X sort(pp->hand);
- X else
- X for (i = 1; i < HAND_SZ; i++)
- X if (pp->hand[i] == C_INIT) {
- X for (j = 0; pp->hand[j] == C_INIT; j++)
- X if (j >= HAND_SZ) {
- X j = 0;
- X break;
- X }
- X pp->hand[i] = pp->hand[j];
- X pp->hand[j] = C_INIT;
- X }
- X if (Topcard <= Deck)
- X check_go();
- X if (Next)
- X nextplay();
- X}
- X
- X/*
- X * Check and see if either side can go. If they cannot,
- X * the game is over
- X */
- Xcheck_go() {
- X
- X reg CARD card;
- X reg PLAY *pp, *op;
- X reg int i;
- X
- X for (pp = Player; pp < &Player[2]; pp++) {
- X op = (pp == &Player[COMP] ? &Player[PLAYER] : &Player[COMP]);
- X for (i = 0; i < HAND_SZ; i++) {
- X card = pp->hand[i];
- X if (issafety(card) || canplay(pp, op, card)) {
- X if (Debug) {
- X fprintf(outf, "CHECK_GO: can play %s (%d), ", C_name[card], card);
- X fprintf(outf, "issafety(card) = %d, ", issafety(card));
- X fprintf(outf, "canplay(pp, op, card) = %d\n", canplay(pp, op, card));
- X }
- X return;
- X }
- X else if (Debug)
- X fprintf(outf, "CHECK_GO: cannot play %s\n",
- X C_name[card]);
- X }
- X }
- X Finished = TRUE;
- X}
- X
- Xchar *
- Xplaycard(pp)
- Xreg PLAY *pp;
- X{
- X reg int v;
- X reg CARD card;
- X
- X /*
- X * check and see if player has picked
- X */
- X switch (pp->hand[Card_no]) {
- X default:
- X if (!haspicked(pp))
- Xmustpick:
- X return ("must pick first");
- X case C_GAS_SAFE: case C_SPARE_SAFE:
- X case C_DRIVE_SAFE: case C_RIGHT_WAY:
- X break;
- X }
- X
- X card = pp->hand[Card_no];
- X if (Debug)
- X fprintf(outf, "PLAYCARD: Card = %s\n", C_name[card]);
- X Next = FALSE;
- X switch (card) {
- X case C_200:
- X if (pp->nummiles[C_200] == 2)
- X return ("only two 200's per hand");
- X case C_100: case C_75:
- X if (pp->speed == C_LIMIT)
- X return ("limit of 50");
- X case C_50:
- X if (pp->mileage + Value[card] > End)
- X return sprint ("puts you over %d", End);
- X case C_25:
- X if (!pp->can_go)
- X return ("cannot move now");
- X#ifdef ANIMATE
- X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_MILES, card);
- X#endif
- X pp->nummiles[card]++;
- X v = Value[card];
- X pp->total += v;
- X pp->hand_tot += v;
- X if ((pp->mileage += v) == End)
- X check_ext(FALSE);
- X break;
- X
- X case C_GAS: case C_SPARE: case C_REPAIRS:
- X if (pp->battle != opposite(card))
- X return sprint ("can't play \"%s\"", C_name[card]);
- X#ifdef ANIMATE
- X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_BATTLE, card);
- X#endif
- X pp->battle = card;
- X if (pp->safety[S_RIGHT_WAY] == S_PLAYED)
- X pp->can_go = TRUE;
- X break;
- X
- X case C_GO:
- X if (pp->battle != C_INIT && pp->battle != C_STOP
- X && !isrepair(pp->battle))
- X return sprint ("cannot play \"Go\" on a \"%s\"",
- X C_name[pp->battle]);
- X#ifdef ANIMATE
- X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_BATTLE, card);
- X#endif
- X pp->battle = C_GO;
- X pp->can_go = TRUE;
- X break;
- X
- X case C_END_LIMIT:
- X if (pp->speed != C_LIMIT)
- X return ("not limited");
- X#ifdef ANIMATE
- X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_SPEED, card);
- X#endif
- X pp->speed = C_END_LIMIT;
- X break;
- X
- X case C_EMPTY: case C_FLAT: case C_CRASH:
- X case C_STOP:
- X pp = &Player[other(Play)];
- X if (!pp->can_go)
- X return ("opponent cannot go");
- X else if (pp->safety[safety(card) - S_CONV] == S_PLAYED)
- Xprotected:
- X return ("opponent is protected");
- X#ifdef ANIMATE
- X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_OBATTLE, card);
- X#endif
- X pp->battle = card;
- X pp->new_battle = TRUE;
- X pp->can_go = FALSE;
- X pp = &Player[Play];
- X break;
- X
- X case C_LIMIT:
- X pp = &Player[other(Play)];
- X if (pp->speed == C_LIMIT)
- X return ("opponent has limit");
- X if (pp->safety[S_RIGHT_WAY] == S_PLAYED)
- X goto protected;
- X#ifdef ANIMATE
- X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_OSPEED, card);
- X#endif
- X pp->speed = C_LIMIT;
- X pp->new_speed = TRUE;
- X pp = &Player[Play];
- X break;
- X
- X case C_GAS_SAFE: case C_SPARE_SAFE:
- X case C_DRIVE_SAFE: case C_RIGHT_WAY:
- X if (pp->battle == opposite(card)
- X || (card == C_RIGHT_WAY && pp->speed == C_LIMIT)) {
- X if (!(card == C_RIGHT_WAY && !isrepair(pp->battle))) {
- X pp->battle = C_GO;
- X pp->can_go = TRUE;
- X }
- X if (card == C_RIGHT_WAY && pp->speed == C_LIMIT)
- X pp->speed = C_INIT;
- X if (pp->new_battle
- X || (pp->new_speed && card == C_RIGHT_WAY)) {
- X pp->coups[card - S_CONV] = TRUE;
- X pp->total += SC_COUP;
- X pp->hand_tot += SC_COUP;
- X pp->coupscore += SC_COUP;
- X }
- X }
- X /*
- X * if not coup, must pick first
- X */
- X else if (pp->hand[0] == C_INIT && Topcard > Deck)
- X goto mustpick;
- X#ifdef ANIMATE
- X animate_move (Play, ANIMATE_HAND, Card_no, ANIMATE_SAFETY, card);
- X#endif
- X pp->safety[card - S_CONV] = S_PLAYED;
- X pp->total += SC_SAFETY;
- X pp->hand_tot += SC_SAFETY;
- X if ((pp->safescore += SC_SAFETY) == NUM_SAFE * SC_SAFETY) {
- X pp->total += SC_ALL_SAFE;
- X pp->hand_tot += SC_ALL_SAFE;
- X }
- X if (card == C_RIGHT_WAY) {
- X if (pp->speed == C_LIMIT)
- X pp->speed = C_INIT;
- X if (pp->battle == C_STOP || pp->battle == C_INIT) {
- X pp->can_go = TRUE;
- X pp->battle = C_INIT;
- X }
- X if (!pp->can_go && isrepair(pp->battle))
- X pp->can_go = TRUE;
- X }
- X Next = -1;
- X break;
- X
- X case C_INIT:
- X Next = -1;
- X return ("no card there");
- X break;
- X }
- X if (pp == &Player[PLAYER])
- X account(card);
- X pp->hand[Card_no] = C_INIT;
- X Next = (Next == -1 ? FALSE : TRUE);
- X return 0;
- X}
- X
- Xchar *
- Xsprint (string, arg)
- X{
- X static char buf[512];
- X
- X sprintf (buf, string, arg);
- X return buf;
- X}
- X
- X/*
- X * return whether or not the player has picked
- X */
- Xhaspicked(pp)
- Xreg PLAY *pp; {
- X
- X reg int card;
- X
- X if (Topcard <= Deck)
- X return TRUE;
- X switch (pp->hand[Card_no]) {
- X case C_GAS_SAFE: case C_SPARE_SAFE:
- X case C_DRIVE_SAFE: case C_RIGHT_WAY:
- X card = 1;
- X break;
- X default:
- X card = 0;
- X break;
- X }
- X return (pp->hand[card] != C_INIT);
- X}
- X
- Xaccount(card)
- Xreg CARD card; {
- X
- X reg CARD oppos;
- X
- X if (card == C_INIT)
- X return;
- X ++Numseen[card];
- X if (Play == COMP)
- X switch (card) {
- X case C_GAS_SAFE:
- X case C_SPARE_SAFE:
- X case C_DRIVE_SAFE:
- X oppos = opposite(card);
- X Numgos += Numcards[oppos] - Numseen[oppos];
- X break;
- X case C_CRASH:
- X case C_FLAT:
- X case C_EMPTY:
- X case C_STOP:
- X Numgos++;
- X break;
- X }
- X}
- X
- Xsort(hand)
- Xreg CARD *hand;
- X{
- X reg CARD *cp, *tp;
- X reg int j;
- X reg CARD temp;
- X
- X cp = hand;
- X hand += HAND_SZ;
- X for ( ; cp < &hand[-1]; cp++)
- X for (tp = cp + 1; tp < hand; tp++)
- X if (*cp > *tp) {
- X temp = *cp;
- X *cp = *tp;
- X *tp = temp;
- X }
- X}
- END_OF_move.c
- if test 8310 -ne `wc -c <move.c`; then
- echo shar: \"move.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f print.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"print.c\"
- else
- echo shar: Extracting \"print.c\" \(65 characters\)
- sed "s/^X//" >print.c <<'END_OF_print.c'
- X# include "mille.h"
- X
- X/*
- X * @(#)print.c 1.1 (Berkeley) 4/1/82
- X */
- END_OF_print.c
- if test 65 -ne `wc -c <print.c`; then
- echo shar: \"print.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f roll.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"roll.c\"
- else
- echo shar: Extracting \"roll.c\" \(575 characters\)
- sed "s/^X//" >roll.c <<'END_OF_roll.c'
- X/*
- X * This routine rolls ndie nside-sided dice.
- X *
- X * @(#)roll.c 1.1 (Berkeley) 4/1/82
- X *
- X */
- X
- X# define reg register
- X
- X# ifndef vax
- X# define MAXRAND 32767L
- X
- Xroll(ndie, nsides)
- Xint ndie, nsides; {
- X
- X reg long tot;
- X reg unsigned n, r;
- X
- X tot = 0;
- X n = ndie;
- X while (n--)
- X tot += rand();
- X return (int) ((tot * (long) nsides) / ((long) MAXRAND + 1)) + ndie;
- X}
- X
- X# else
- X
- Xroll(ndie, nsides)
- Xreg int ndie, nsides; {
- X
- X reg int tot, r;
- X reg double num_sides;
- X
- X num_sides = nsides;
- X tot = 0;
- X while (ndie--)
- X tot += (r = rand()) * (num_sides / 017777777777) + 1;
- X return tot;
- X}
- X# endif
- END_OF_roll.c
- if test 575 -ne `wc -c <roll.c`; then
- echo shar: \"roll.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f save.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"save.c\"
- else
- echo shar: Extracting \"save.c\" \(1815 characters\)
- sed "s/^X//" >save.c <<'END_OF_save.c'
- X#include "mille.h"
- X#include <sys/types.h>
- X#include <sys/stat.h>
- X#include <sys/time.h>
- X# ifdef attron
- X# include <term.h>
- X# define _tty cur_term->Nttyb
- X# endif attron
- X
- X/*
- X * @(#)save.c 1.4 (Berkeley) 7/3/83
- X */
- X
- Xtypedef struct stat STAT;
- Xtypedef struct tm TIME;
- X
- Xchar *ctime();
- X
- Xint read(), write();
- X
- X/*
- X * This routine saves the current game for use at a later date
- X */
- Xextern int errno;
- Xextern char *sys_errlist[];
- X
- Xsave() {
- X
- X reg char *sp;
- X reg int outf;
- X reg TIME *tp;
- X char buf[80];
- X TIME tme;
- X STAT junk;
- X
- X tp = &tme;
- X if (Fromfile && getyn("Same file? "))
- X strcpy(buf, Fromfile);
- X else {
- Xover:
- X
- X strcpy (buf, GetpromptedInput ("file: "));
- X sp = buf + strlen (buf);
- X }
- X
- X /*
- X * check for existing files, and confirm overwrite if needed
- X */
- X
- X if (sp == buf || (!Fromfile && stat(buf, &junk) > -1
- X && getyn("Overwrite File? ") == FALSE))
- X return FALSE;
- X
- X if ((outf = creat(buf, 0644)) < 0) {
- X error(sys_errlist[errno]);
- X return FALSE;
- X }
- X Error (buf);
- X time(tp); /* get current time */
- X strcpy(buf, ctime(tp));
- X for (sp = buf; *sp != '\n'; sp++)
- X continue;
- X *sp = '\0';
- X varpush(outf, write);
- X close(outf);
- X return TRUE;
- X}
- X
- X/*
- X * This does the actual restoring. It returns TRUE if the
- X * backup was made on exiting, in which case certain things must
- X * be cleaned up before the game starts.
- X */
- Xrest_f(file)
- Xreg char *file; {
- X
- X reg char *sp;
- X reg int inf;
- X char buf[80];
- X STAT sbuf;
- X
- X if ((inf = open(file, 0)) < 0) {
- X perror(file);
- X exit(1);
- X }
- X if (fstat(inf, &sbuf) < 0) { /* get file stats */
- X perror(file);
- X exit(1);
- X }
- X varpush(inf, read);
- X close(inf);
- X strcpy(buf, ctime(&sbuf.st_mtime));
- X for (sp = buf; *sp != '\n'; sp++)
- X continue;
- X *sp = '\0';
- X /*
- X * initialize some necessary values
- X */
- X sprintf(Initstr, "%s [%s]\n", file, buf);
- X Fromfile = file;
- X return !On_exit;
- X}
- END_OF_save.c
- if test 1815 -ne `wc -c <save.c`; then
- echo shar: \"save.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f table.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"table.c\"
- else
- echo shar: Extracting \"table.c\" \(431 characters\)
- sed "s/^X//" >table.c <<'END_OF_table.c'
- X# define DEBUG
- X
- X/*
- X * @(#)table.c 1.1 (Berkeley) 4/1/82
- X */
- X
- X# include "mille.h"
- X
- Xmain() {
- X
- X reg int i, j, count;
- X
- X printf(" %16s -> %5s %5s %4s %s\n", "Card", "cards", "count", "need", "opposite");
- X for (i = 0; i < NUM_CARDS - 1; i++) {
- X for (j = 0, count = 0; j < DECK_SZ; j++)
- X if (Deck[j] == i)
- X count++;
- X printf("%2d %16s -> %5d %5d %4d %s\n", i, C_name[i], Numcards[i], count, Numneed[i], C_name[opposite(i)]);
- X }
- X}
- END_OF_table.c
- if test 431 -ne `wc -c <table.c`; then
- echo shar: \"table.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f types.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"types.c\"
- else
- echo shar: Extracting \"types.c\" \(597 characters\)
- sed "s/^X//" >types.c <<'END_OF_types.c'
- X# include "mille.h"
- X
- X/*
- X * @(#)types.c 1.1 (Berkeley) 4/1/82
- X */
- X
- Xisrepair(card)
- Xreg CARD card; {
- X
- X return card == C_GAS || card == C_SPARE || card == C_REPAIRS || card == C_INIT;
- X}
- X
- Xsafety(card)
- Xreg CARD card; {
- X
- X switch (card) {
- X case C_EMPTY:
- X case C_GAS:
- X case C_GAS_SAFE:
- X return C_GAS_SAFE;
- X case C_FLAT:
- X case C_SPARE:
- X case C_SPARE_SAFE:
- X return C_SPARE_SAFE;
- X case C_CRASH:
- X case C_REPAIRS:
- X case C_DRIVE_SAFE:
- X return C_DRIVE_SAFE;
- X case C_GO:
- X case C_STOP:
- X case C_RIGHT_WAY:
- X case C_LIMIT:
- X case C_END_LIMIT:
- X return C_RIGHT_WAY;
- X }
- X /* NOTREACHED */
- X}
- END_OF_types.c
- if test 597 -ne `wc -c <types.c`; then
- echo shar: \"types.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f ui.h -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"ui.h\"
- else
- echo shar: Extracting \"ui.h\" \(2948 characters\)
- sed "s/^X//" >ui.h <<'END_OF_ui.h'
- X# include "color.h"
- X# include <X/Xlib.h>
- X# include "control/control.h"
- X
- Xextern Window xwindow;
- Xextern FontInfo *font;
- Xextern Bitmap fill;
- X
- Xstruct plane {
- X Bitmap bits;
- X int pixel;
- X};
- X
- Xstruct card {
- X int nPlanes;
- X struct plane planes[5];
- X};
- X
- Xextern struct card cards[];
- Xextern struct card backside;
- Xextern struct card eraseCard;
- X
- X
- Xstruct safety_offset {
- X int x;
- X int y;
- X};
- X
- Xextern struct safety_offset safety_offsets[4];
- X
- X# define PAD_CARD (5)
- X# define MILE_OFFSET (5)
- X# define PAD_TEXT (20)
- X# define DIST_HEIGHT (15)
- X# define DIST_WIDTH ((WIDTH + PAD_CARD) * 5 - PAD_CARD)
- X# define DIST_MARK (4)
- X
- X# define COMP_HAND_X (PAD_CARD)
- X# define COMP_HAND_Y (-HEIGHT)
- X# define COMP_DIST_TX (PAD_CARD + (WIDTH + PAD_CARD) * 2)
- X# define COMP_DIST_TY (PAD_CARD)
- X# define COMP_DIST_MX (COMP_DIST_TX)
- X# define COMP_DIST_MY (COMP_DIST_TY + PAD_TEXT)
- X# define COMP_DIST_X (COMP_DIST_MX)
- X# define COMP_DIST_Y (COMP_DIST_MY + DIST_MARK + 1)
- X
- X# define COMP_PLAY_X PAD_CARD
- X# define COMP_PLAY_Y (COMP_DIST_Y + DIST_HEIGHT + PAD_CARD)
- X
- X# define COMP_SAFE_X (COMP_PLAY_X + ((WIDTH + PAD_CARD) * 7))
- X# define COMP_SAFE_Y COMP_PLAY_Y
- X
- X# define COMP_CARD_TX PAD_CARD
- X# define COMP_CARD_TY (COMP_PLAY_Y + HEIGHT + 6 * MILE_OFFSET + PAD_CARD)
- X# define COMP_CARD_X COMP_CARD_TX
- X# define COMP_CARD_Y (COMP_CARD_TY + PAD_TEXT)
- X
- X# define MESS_X (PAD_CARD)
- X# define MESS_Y (COMP_PLAY_Y + HEIGHT + 6 * MILE_OFFSET + PAD_CARD + PAD_TEXT)
- X# define MESS_W 150
- X# define MESS_H (font->height)
- X# define PROMPT_X MESS_X
- X# define PROMPT_Y (MESS_Y + PAD_TEXT)
- X# define PROMPT_W (MESS_W)
- X# define PROMPT_H (MESS_H)
- X# define ERROR_X PROMPT_X
- X# define ERROR_Y (PROMPT_Y + PAD_TEXT)
- X# define ERROR_W (MESS_W)
- X# define ERROR_H (MESS_H)
- X
- X# define QUIT_X (MESS_X)
- X# define QUIT_Y (ERROR_Y + PAD_TEXT + PAD_CARD)
- X# define SAVE_X (QUIT_X + 75)
- X# define SAVE_Y (QUIT_Y)
- X
- X# define DISCARD_TX (MESS_X + MESS_W + PAD_CARD)
- X# define DISCARD_TY (MESS_Y - PAD_TEXT)
- X# define DISCARD_X (DISCARD_TX)
- X# define DISCARD_Y (DISCARD_TY + PAD_TEXT)
- X
- X# define DECK_TX (DISCARD_X + WIDTH + PAD_CARD)
- X# define DECK_TY (DISCARD_TY)
- X# define DECK_X (DECK_TX)
- X# define DECK_Y (DISCARD_Y)
- X
- X# define SCORE_W (100)
- X# define SCORE_H (font->height)
- X# define SCORE_N 13
- X# define SCORE_X (DECK_X + WIDTH + PAD_CARD + SCORE_W)
- X# define SCORE_Y (DECK_TY)
- X
- X# define HUM_DIST_TX (COMP_DIST_TX)
- X# define HUM_DIST_TY (SCORE_Y + SCORE_N * SCORE_H + PAD_CARD)
- X# define HUM_DIST_MX (HUM_DIST_TX)
- X# define HUM_DIST_MY (HUM_DIST_TY + PAD_TEXT)
- X# define HUM_DIST_X (HUM_DIST_MX)
- X# define HUM_DIST_Y (HUM_DIST_MY + DIST_MARK + 1)
- X
- X# define HUM_PLAY_X PAD_CARD
- X# define HUM_PLAY_Y (HUM_DIST_Y + DIST_HEIGHT + PAD_CARD)
- X# define HUM_SAFE_X (HUM_PLAY_X + ((WIDTH + PAD_CARD) * 7))
- X# define HUM_SAFE_Y (HUM_PLAY_Y)
- X
- X# define HUM_HAND_X PAD_CARD
- X# define HUM_HAND_Y (HUM_PLAY_Y + HEIGHT + 6 * MILE_OFFSET + PAD_CARD)
- X
- X# define WINDOW_WIDTH (HUM_SAFE_X + (WIDTH + PAD_CARD) * 2)
- X# define WINDOW_HEIGHT (HUM_HAND_Y + HEIGHT + PAD_CARD)
- END_OF_ui.h
- if test 2948 -ne `wc -c <ui.h`; then
- echo shar: \"ui.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f varpush.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"varpush.c\"
- else
- echo shar: Extracting \"varpush.c\" \(1170 characters\)
- sed "s/^X//" >varpush.c <<'END_OF_varpush.c'
- X# include "mille.h"
- X
- X/*
- X * @(#)varpush.c 1.1 (Berkeley) 4/1/82
- X */
- X
- Xint read(), write();
- X
- X/*
- X * push variables around via the routine func() on the file
- X * channel file. func() is either read or write.
- X */
- Xvarpush(file, func)
- Xreg int file;
- Xreg int (*func)(); {
- X
- X int temp;
- X
- X (*func)(file, &Debug, sizeof Debug);
- X (*func)(file, &Finished, sizeof Finished);
- X (*func)(file, &Order, sizeof Order);
- X (*func)(file, &End, sizeof End);
- X (*func)(file, &On_exit, sizeof On_exit);
- X (*func)(file, &Handstart, sizeof Handstart);
- X (*func)(file, &Numgos, sizeof Numgos);
- X (*func)(file, Numseen, sizeof Numseen);
- X (*func)(file, &Play, sizeof Play);
- X (*func)(file, &WIndow, sizeof WIndow);
- X (*func)(file, Deck, sizeof Deck);
- X (*func)(file, &Discard, sizeof Discard);
- X (*func)(file, Player, sizeof Player);
- X if (func == read) {
- X read(file, &temp, sizeof temp);
- X Topcard = &Deck[temp];
- X if (Debug) {
- X char buf[80];
- Xover:
- X printf("Debug file:");
- X gets(buf);
- X if ((outf = fopen(buf, "w")) == NULL) {
- X perror(buf);
- X goto over;
- X }
- X if (strcmp(buf, "/dev/null") != 0)
- X setbuf(outf, 0);
- X }
- X }
- X else {
- X temp = Topcard - Deck;
- X write(file, &temp, sizeof temp);
- X }
- X}
- END_OF_varpush.c
- if test 1170 -ne `wc -c <varpush.c`; then
- echo shar: \"varpush.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- echo shar: End of archive 2 \(of 3\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 3 archives.
- echo "Now uudecode and uncompress 'cards.Z.uu' and feed to sh"
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-